#!/usr/bin/env python
# encoding=utf8
"""
@summary: 搜狐汽车地域分布情况
@attention: 转化地域以及发送邮件
@author: hongxingfan
@since: 2014年8月5日	上午11:53:48
"""
import sys

hash_result = {}

if __name__ == "__main__":
	for line in sys.stdin:
		line = line.strip()
		cols = line.split("\t")

		region = cols[0]
		pv = int(cols[1])
		suv = cols[2]

		if region in hash_result:
			value = hash_result.get(region)
			value[0] += 1
			value[1].add(suv)
		else:
			hash_result[region] = [pv, set([suv])]
	# #打印最终结果
	for (k, v) in hash_result.items():
		print("%s\t%s\t%s" % (k, v[0], len(v[1])))
